:root {
  --color-bg: #f4f7f4;
  --color-card: #ffffff;
  --color-primary: #2e7d32;
  --color-primary-light: #e8f5e9;
  --color-border: #d8e2d8;
  --color-text: #2b2b2b;
  --color-muted: #6b7a6b;
  --gantt-row-height: 36px;
  --gantt-px-per-day: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

header {
  background: var(--color-primary);
  color: #fff;
  padding: 16px 20px;
}

header h1 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}

.sync-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sync-bar button,
.import-label {
  background: #ffffff;
  color: var(--color-primary);
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: bold;
}

.import-label {
  position: relative;
  overflow: hidden;
  display: inline-block;
}

.import-label input[type="file"] {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

.reload-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 1000;
}

.reload-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.autosave-status {
  margin-left: auto;
  font-size: 0.8rem;
  opacity: 0.85;
}

.last-updated {
  font-size: 0.8rem;
  opacity: 0.85;
}

.sync-note {
  margin: 8px 0 0;
  font-size: 0.78rem;
  opacity: 0.9;
}

nav.tabs {
  display: flex;
  gap: 4px;
  background: #ffffff;
  border-bottom: 2px solid var(--color-border);
  padding: 0 12px;
  flex-wrap: wrap;
}

.tab-btn {
  background: none;
  border: none;
  padding: 12px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--color-muted);
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: bold;
}

main {
  padding: 16px 20px 60px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

h2 {
  font-size: 1.05rem;
  border-left: 4px solid var(--color-primary);
  padding-left: 8px;
  margin: 20px 0 10px;
}

.hint {
  color: var(--color-muted);
  font-size: 0.8rem;
}

.kv-table {
  border-collapse: collapse;
  width: 100%;
  max-width: 800px;
  background: var(--color-card);
}

.kv-table td {
  border: 1px solid var(--color-border);
  padding: 8px 10px;
  vertical-align: top;
}

.kv-table td:first-child {
  width: 160px;
  background: var(--color-primary-light);
  font-weight: bold;
}

.kv-table td[contenteditable="true"]:focus {
  outline: 2px solid var(--color-primary);
}

.link-list { padding-left: 20px; }
.link-list a { color: var(--color-primary); }

.data-table {
  border-collapse: collapse;
  width: 100%;
  background: var(--color-card);
}

.data-table th, .data-table td {
  border: 1px solid var(--color-border);
  padding: 6px 8px;
  font-size: 0.85rem;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: var(--color-primary-light);
}

.data-table td[contenteditable="true"] {
  min-width: 60px;
}

.data-table td[contenteditable="true"]:focus {
  outline: 2px solid var(--color-primary);
  background: #fffef0;
}

.data-table input, .data-table select {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.85rem;
  font-family: inherit;
}

.data-table input:focus, .data-table select:focus {
  border-color: var(--color-primary);
  background: #fffef0;
  outline: none;
}

.row-delete-btn {
  background: none;
  border: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 0.9rem;
}

.row-add-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: bold;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.wbs-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.wbs-toolbar button {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
}

.wbs-layout {
  display: flex;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  overflow: hidden;
}

.wbs-table-wrap {
  flex: 0 0 auto;
  overflow: visible;
}

.wbs-table-wrap .data-table {
  width: auto;
}

.wbs-table-wrap th, .wbs-table-wrap td {
  height: var(--gantt-row-height);
  white-space: nowrap;
}

.wbs-table-wrap td:nth-child(1) { min-width: 32px; text-align: center; color: var(--color-muted); }
.wbs-table-wrap td:nth-child(2) { min-width: 160px; white-space: normal; }
.wbs-table-wrap td:nth-child(3) { min-width: 200px; white-space: normal; }
.wbs-table-wrap td:nth-child(4) { min-width: 110px; }
.wbs-table-wrap td:nth-child(5),
.wbs-table-wrap td:nth-child(6) { min-width: 120px; }
.wbs-table-wrap td:nth-child(7) { min-width: 90px; }

/* 課題&Todoテーブル: タイトル・メモは広め、他のカラムは内容に合わせて最小幅に */
.issues-table td:nth-child(1),
.issues-table td:nth-child(3),
.issues-table td:nth-child(4),
.issues-table td:nth-child(5),
.issues-table td:nth-child(7) {
  width: 1%;
  white-space: nowrap;
}

.issues-table td:nth-child(1) select,
.issues-table td:nth-child(4) select {
  width: auto;
}

.issues-table td:nth-child(3) input {
  width: 5em;
}

.issues-table td:nth-child(5) input {
  width: auto;
}

.issues-table td:nth-child(2),
.issues-table td:nth-child(6) {
  min-width: 240px;
}

/* GREEN EXPO タブ */
.expo-hero {
  margin-bottom: 8px;
}

.expo-hero img {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.expo-catch {
  margin: 8px 0 0;
  font-weight: bold;
  color: var(--color-primary);
  font-size: 1rem;
}

.expo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.expo-figure {
  margin: 0;
  flex: 1 1 320px;
  max-width: 520px;
}

.expo-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  cursor: zoom-in;
}

.expo-figure figcaption {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.gantt-wrap {
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  border-left: 1px solid var(--color-border);
}

.gantt-header {
  position: relative;
  height: 38px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-primary-light);
}

.gantt-month {
  position: absolute;
  top: 0;
  height: 100%;
  border-right: 1px solid var(--color-border);
  font-size: 0.75rem;
  padding: 4px 4px 0;
  color: var(--color-muted);
  box-sizing: border-box;
}

.gantt-body {
  position: relative;
}

.gantt-row {
  position: relative;
  height: var(--gantt-row-height);
  border-bottom: 1px solid var(--color-border);
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(var(--gantt-px-per-day) * 7 - 1px),
    var(--color-border) calc(var(--gantt-px-per-day) * 7 - 1px),
    var(--color-border) calc(var(--gantt-px-per-day) * 7)
  );
}

.gantt-bar {
  position: absolute;
  top: 6px;
  height: calc(var(--gantt-row-height) - 12px);
  background: var(--color-primary);
  border-radius: 4px;
  min-width: 4px;
}

.gantt-bar.status-完了 { background: #9e9e9e; }
.gantt-bar.status-進行中 { background: #f9a825; }
.gantt-bar.status-未着手 { background: var(--color-primary); }

.gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e53935;
  z-index: 2;
}

.gantt-today::after {
  content: "今日";
  position: absolute;
  top: -16px;
  left: -10px;
  font-size: 0.7rem;
  color: #e53935;
  white-space: nowrap;
}

.editable-list {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  padding: 10px 10px 10px 30px;
}

.editable-list li {
  margin-bottom: 6px;
}

.agenda-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.agenda-move {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.row-move-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.65rem;
  padding: 0;
}

.row-move-btn:disabled {
  color: var(--color-border);
  cursor: default;
}

.agenda-text {
  flex: 1;
}

.agenda-text[contenteditable="true"]:focus {
  outline: 2px solid var(--color-primary);
  background: #fffef0;
}

.kv-row {
  margin-bottom: 10px;
}

.minutes-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 10px;
}

.minutes-card h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.minutes-card .field-label {
  font-size: 0.75rem;
  color: var(--color-muted);
  display: block;
  margin-top: 6px;
}

.minutes-card [contenteditable="true"]:focus,
.minutes-card input:focus {
  outline: 2px solid var(--color-primary);
  background: #fffef0;
}

.minutes-card input {
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 2px 6px;
  font-family: inherit;
}

#addWbsRowBtn, #addMinutesBtn, #addAgendaItemBtn, #addIssueBtn, #addTeamBtn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  margin-bottom: 10px;
}

/* ---------- パスワードロック画面 ---------- */
body.locked { overflow: hidden; }
.pin-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1b5e20, #2e7d32);
  padding: 20px;
}
/* hidden属性のときは確実に隠す（.pin-gateのdisplay:flexに勝たせる） */
.pin-gate[hidden] { display: none !important; }
.pin-card {
  background: #fff; border-radius: 16px; padding: 32px 28px;
  width: 100%; max-width: 340px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.pin-card .pin-emoji { font-size: 40px; }
.pin-card h2 { margin: 8px 0 4px; font-size: 1.1rem; color: #1b5e20; line-height: 1.4; }
.pin-card p { margin: 4px 0 16px; color: #555; font-size: .9rem; }
.pin-card input {
  width: 100%; box-sizing: border-box; font-size: 1.6rem; text-align: center;
  letter-spacing: .4em; padding: 12px; border: 2px solid #c8e6c9; border-radius: 10px;
  margin-bottom: 16px;
}
.pin-card input:focus { outline: none; border-color: #2e7d32; }
.pin-card button {
  width: 100%; padding: 12px; font-size: 1rem; font-weight: bold;
  color: #fff; background: #2e7d32; border: none; border-radius: 10px; cursor: pointer;
}
.pin-card button:hover { background: #1b5e20; }
.pin-error { color: #c62828 !important; font-weight: bold; margin-top: 12px !important; }

/* 議事録のDriveリンク（クリックで開く） */
.drive-open-link {
  display: inline-block; margin: 2px 0 6px; font-size: .9rem; font-weight: bold;
  color: #1565c0; text-decoration: none;
}
.drive-open-link:hover { text-decoration: underline; }

/* ===== スマホ対応 ===== */
@media (max-width: 768px) {
  /* WBS: 表（左）＋ガント（右）を横一続きにし、レイアウト全体を横スクロール。
     右へスワイプすると 担当・日付・状態…そしてガントのバーが現れる（行は揃ったまま）。 */
  .wbs-layout { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .wbs-table-wrap { flex: 0 0 auto; overflow: visible; }
  .gantt-wrap { flex: 0 0 auto; overflow: visible; }
}
