* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #43A047;
  --orange: #FF7043;
  --blue: #29B6F6;
  --bg: #FAFAFA;
  --text: #333333;
}

body {
  font-family: 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ヘッダー */
header {
  background: var(--green);
  color: white;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 600px;
  margin: 0 auto;
}

.logo { font-size: 20px; color: #fff; text-decoration: none; }
h1 { font-size: 18px; font-weight: bold; flex: 1; }

/* 同期バッジ（ヘッダー右） */
.sync-badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  flex-shrink: 0;
}
.sync-badge.connected   { background: #A5D6A7; }
.sync-badge.connecting  { background: #FFE082; animation: blink 1s infinite; }
.sync-badge.error       { background: #EF9A9A; }

@keyframes blink {
  0%,100% { opacity:1; } 50% { opacity:0.2; }
}

main {
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: 80px;
}

/* タブ */
.tabs {
  display: flex;
  border-bottom: 2px solid #e0e0e0;
  background: white;
  position: sticky;
  top: 49px;
  z-index: 99;
}

.tab {
  flex: 1;
  padding: 11px 4px;
  border: none;
  background: none;
  font-size: 12px;
  color: #888;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

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

.tab-content { display: none; padding: 16px; }
.tab-content.active { display: block; }

/* モード切替 */
.map-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.map-controls button {
  flex: 1;
  padding: 9px 6px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

#btn-place-mode.active { border-color: var(--green); background: #E8F5E9; color: #2E7D32; font-weight: bold; }
#btn-water-mode.active { border-color: var(--blue); background: #E1F5FE; color: #0288D1; font-weight: bold; }
.btn-settings { flex: 0.7 !important; font-size: 12px !important; color: #666; }
.btn-settings.active { border-color: #888 !important; background: #f5f5f5 !important; color: #333 !important; }

/* グリッド設定パネル */
.settings-panel {
  display: none;
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.settings-panel.open { display: block; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.settings-row + .settings-row { border-top: 1px solid #eee; }
.settings-label { font-size: 13px; color: #555; }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper-btn {
  width: 32px; height: 32px;
  border: 1px solid #ddd; border-radius: 50%;
  background: white; font-size: 18px;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center; color: #555;
}
.stepper-btn:active { background: #eee; }
.stepper-value { font-size: 18px; font-weight: bold; min-width: 24px; text-align: center; }

.size-buttons { display: flex; gap: 6px; }
.size-btn {
  padding: 6px 14px; border: 1px solid #ddd;
  border-radius: 6px; background: white;
  font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.size-btn.active { border-color: var(--green); background: #E8F5E9; color: #2E7D32; font-weight: bold; }

/* ヒント */
.map-hint {
  text-align: center; font-size: 13px; color: #666;
  margin-bottom: 10px; padding: 8px;
  background: #f5f5f5; border-radius: 8px;
}

/* パレット */
.plant-palette {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 10px; min-height: 48px;
}

.palette-plant {
  display: flex; flex-direction: column; align-items: center;
  padding: 5px 8px; border: 2px solid #e0e0e0;
  border-radius: 8px; background: white;
  cursor: pointer; font-size: 11px;
  transition: all 0.2s; user-select: none;
}

.palette-plant .plant-visual {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 2px;
}

.palette-plant .plant-visual img {
  width: 28px; height: 28px;
  object-fit: cover; border-radius: 4px;
}

.palette-plant .plant-visual .plant-emoji { font-size: 22px; line-height: 1; }

.palette-plant.water-high  { border-left: 4px solid var(--blue); }
.palette-plant.water-normal { border-left: 4px solid var(--green); }
.palette-plant.water-low   { border-left: 4px solid var(--orange); }
.palette-plant.selected    { box-shadow: 0 0 0 2px var(--green); background: #E8F5E9; }

/* グリッド */
.grid-container {
  border: 2px solid #e0e0e0; border-radius: 12px;
  background: #F1F8E9; padding: 6px;
  touch-action: none; user-select: none;
}

.grid { display: grid; gap: 3px; }

.grid-cell {
  border-radius: 5px; background: white;
  border: 1px solid #ddd;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  transition: background 0.3s; overflow: hidden;
  aspect-ratio: 1;
}

.grid-cell.has-plant { border-width: 2px; }
.grid-cell.water-high   { border-color: var(--blue); }
.grid-cell.water-normal { border-color: var(--green); }
.grid-cell.water-low    { border-color: var(--orange); }

.cell-visual {
  display: flex; align-items: center; justify-content: center;
}

.cell-visual img {
  object-fit: cover; border-radius: 3px;
}

/* マスの大きさ別 */
.size-small .cell-visual img  { width: 18px; height: 18px; }
.size-small .cell-visual .plant-emoji { font-size: 13px; }
.size-small .cell-name  { display: none; }
.size-small .grid        { gap: 2px; }

.size-medium .cell-visual img  { width: 26px; height: 26px; }
.size-medium .cell-visual .plant-emoji { font-size: 18px; }
.size-medium .cell-name { font-size: 8px; color: #555; text-align: center; line-height: 1.1; }

.size-large .cell-visual img  { width: 34px; height: 34px; }
.size-large .cell-visual .plant-emoji { font-size: 24px; }
.size-large .cell-name  { font-size: 10px; color: #555; text-align: center; line-height: 1.2; }
.size-large .grid        { gap: 4px; }

/* 水やりエフェクト */
.grid-cell.watered        { background: #B3E5FC; }
.grid-cell.watered-splash { background: #E1F5FE; }

@keyframes ripple {
  0%   { transform: scale(0); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

.water-ripple {
  position: absolute; width: 100%; height: 100%;
  border-radius: 50%;
  background: rgba(41,182,246,0.5);
  animation: ripple 0.4s ease-out forwards;
  pointer-events: none;
}

/* アドバイス */
.advice-box {
  margin-top: 10px; padding: 12px; border-radius: 8px;
  font-size: 13px; line-height: 1.6; display: none;
}
.advice-box.warning { background: #FFF3E0; border-left: 4px solid var(--orange); display: block; }
.advice-box.ok      { background: #E8F5E9; border-left: 4px solid var(--green);  display: block; }

/* セクションヘッダー */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; cursor: pointer;
  border-bottom: 2px solid var(--green); margin-bottom: 12px;
}
.section-header.collapsed { border-bottom-color: #e0e0e0; margin-bottom: 0; }
.section-header h2 { font-size: 15px; font-weight: bold; color: var(--text); margin: 0; }
.toggle-icon { font-size: 12px; color: #888; }

/* カテゴリタブ */
.cat-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.cat-tab {
  flex: 1; padding: 7px 4px;
  border: 1px solid #e0e0e0; border-radius: 8px;
  background: white; font-size: 11px; cursor: pointer;
  transition: all 0.2s; color: #666;
}
.cat-tab.active { background: var(--green); border-color: var(--green); color: white; font-weight: bold; }

/* テンプレートリスト */
.template-item {
  display: flex; align-items: center;
  padding: 10px 12px; background: white;
  border: 1px solid #e0e0e0; border-radius: 8px;
  margin-bottom: 6px; gap: 10px;
}

.template-visual {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; overflow: hidden; background: #f5f5f5;
}
.template-visual img { width: 40px; height: 40px; object-fit: cover; }
.template-visual .plant-emoji { font-size: 26px; }

.template-info { flex: 1; }
.template-name   { font-size: 14px; font-weight: bold; }
.template-detail { font-size: 11px; color: #888; margin-top: 2px; }

.btn-add-template {
  padding: 5px 10px; background: var(--green);
  color: white; border: none; border-radius: 6px;
  font-size: 12px; cursor: pointer;
  white-space: nowrap; flex-shrink: 0; transition: background 0.2s;
}
.btn-add-template:active { background: #388E3C; }

.registered-badge {
  font-size: 11px; color: #888; background: #f0f0f0;
  padding: 4px 8px; border-radius: 6px;
  white-space: nowrap; flex-shrink: 0;
}

/* カスタム登録フォーム */
#custom-section { padding-top: 12px; }

h2.list-title {
  font-size: 15px; font-weight: bold;
  margin: 20px 0 10px;
  padding-bottom: 8px; border-bottom: 2px solid #e0e0e0;
}

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 13px; font-weight: bold;
  margin-bottom: 5px; color: #555;
}
.form-group input, .form-group select {
  width: 100%; padding: 10px 12px;
  border: 2px solid #e0e0e0; border-radius: 8px;
  font-size: 15px; background: white; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--green);
}

.water-need-selector { display: flex; gap: 6px; }
.water-need-btn {
  flex: 1; padding: 8px 4px;
  border: 2px solid #e0e0e0; border-radius: 8px;
  background: white; font-size: 11px; cursor: pointer; transition: all 0.2s;
}
.water-need-btn.active[data-value="high"]   { border-color: var(--blue);   background: #E1F5FE; }
.water-need-btn.active[data-value="normal"] { border-color: var(--green);  background: #E8F5E9; }
.water-need-btn.active[data-value="low"]    { border-color: var(--orange); background: #FFF3E0; }

.btn-primary {
  width: 100%; padding: 12px; background: var(--green);
  color: white; border: none; border-radius: 8px;
  font-size: 15px; font-weight: bold; cursor: pointer; transition: background 0.2s;
}
.btn-primary:active { background: #388E3C; }

/* 植物リスト */
.plant-list-item {
  display: flex; align-items: center;
  padding: 10px 12px; background: white;
  border: 1px solid #e0e0e0; border-radius: 8px;
  margin-bottom: 6px; gap: 10px;
}

.list-visual {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; overflow: hidden; background: #f5f5f5;
}
.list-visual img { width: 36px; height: 36px; object-fit: cover; }
.list-visual .plant-emoji { font-size: 24px; }

.plant-list-info { flex: 1; }
.plant-list-name   { font-weight: bold; font-size: 14px; }
.plant-list-detail { font-size: 11px; color: #888; margin-top: 2px; }

.water-badge {
  font-size: 10px; padding: 3px 7px; border-radius: 10px;
  white-space: nowrap; flex-shrink: 0;
}
.water-badge.high   { background: #E1F5FE; color: #0288D1; }
.water-badge.normal { background: #E8F5E9; color: #2E7D32; }
.water-badge.low    { background: #FFF3E0; color: #E65100; }

.btn-delete {
  background: none; border: none;
  color: #ccc; font-size: 16px; cursor: pointer;
  padding: 4px 6px; flex-shrink: 0;
}
.btn-delete:active { color: var(--orange); }

/* 水やり記録 */
.history-date { font-size: 13px; font-weight: bold; color: #888; margin: 16px 0 6px; }
.history-item {
  display: flex; align-items: center;
  padding: 8px 12px; background: white;
  border: 1px solid #e0e0e0; border-radius: 8px;
  margin-bottom: 6px; font-size: 13px; gap: 8px;
}
.history-item.splash { opacity: 0.65; }
.history-time { margin-left: auto; color: #bbb; font-size: 12px; }

/* 共有タブ */
.sync-status-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: white;
  border: 1px solid #e0e0e0; border-radius: 8px;
  margin-bottom: 16px; font-size: 13px; color: #555;
}

.sync-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #ccc; flex-shrink: 0;
}
.sync-dot.connected  { background: var(--green); }
.sync-dot.connecting { background: #FFA726; animation: blink 1s infinite; }
.sync-dot.error      { background: #F44336; }

.notice-box {
  background: #FFF8E1; border-left: 4px solid #FFC107;
  border-radius: 8px; padding: 12px; font-size: 13px;
  line-height: 1.6; margin-bottom: 16px;
}

.share-card {
  background: white; border: 1px solid #e0e0e0;
  border-radius: 12px; padding: 16px; margin-bottom: 14px;
}
.share-card h2 { font-size: 15px; font-weight: bold; margin-bottom: 6px; }
.share-desc { font-size: 12px; color: #888; margin-bottom: 12px; line-height: 1.5; }

.code-input-row { display: flex; gap: 8px; }
.code-input {
  flex: 1; padding: 10px 14px;
  border: 2px solid #e0e0e0; border-radius: 8px;
  font-size: 18px; font-weight: bold; letter-spacing: 3px;
  text-transform: uppercase; text-align: center;
  -webkit-appearance: none; appearance: none;
}
.code-input:focus { outline: none; border-color: var(--blue); }

.btn-join {
  padding: 10px 18px; background: var(--blue);
  color: white; border: none; border-radius: 8px;
  font-size: 14px; font-weight: bold; cursor: pointer;
}
.btn-join:active { background: #0288D1; }

.big-code {
  font-size: 36px; font-weight: bold; letter-spacing: 6px;
  text-align: center; color: var(--green);
  background: #E8F5E9; border-radius: 10px;
  padding: 16px; margin: 12px 0;
}

.btn-copy {
  width: 100%; padding: 10px; background: white;
  border: 2px solid var(--green); border-radius: 8px;
  color: var(--green); font-size: 14px; font-weight: bold;
  cursor: pointer; transition: all 0.2s;
}
.btn-copy:active { background: #E8F5E9; }

.btn-danger {
  width: 100%; padding: 10px; background: white;
  border: 2px solid #EF5350; border-radius: 8px;
  color: #EF5350; font-size: 14px; cursor: pointer;
  transition: all 0.2s;
}
.btn-danger:active { background: #FFEBEE; }

.divider { border: none; border-top: 1px solid #e0e0e0; margin: 4px 0 16px; }

/* 空の状態 */
.empty-state { text-align: center; color: #bbb; padding: 32px 20px; font-size: 14px; }
.empty-icon  { font-size: 36px; margin-bottom: 8px; }
