:root {
  --bg-color: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.7);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text-main: #ffffff;
  --text-muted: #cbd5e1;
  --accent-color: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.5);
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-border: #334155;
  --success: #10b981;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  padding: 2rem;
  line-height: 1.5;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 2rem;
}

.app-header {
  text-align: center;
  margin-bottom: 1rem;
}

.app-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.app-header .accent {
  color: var(--accent-color);
  text-shadow: 0 0 20px var(--accent-glow);
}

.badge {
  font-size: 0.8rem;
  background: var(--accent-color);
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  vertical-align: middle;
  margin-left: 0.5rem;
}

.app-header p {
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.app-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.75rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.extracted-data {
  background: rgba(0, 0, 0, 0.25);
  padding: 1.25rem;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  border: 1px dashed rgba(255, 255, 255, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

input, textarea, select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

textarea {
  resize: vertical;
}

textarea#log-content {
  min-height: 150px;
}

textarea.readonly-textarea {
  min-height: 3rem;
  resize: none;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-main);
  border-color: #475569;
  line-height: 1.4;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

input[readonly] {
  background: rgba(0,0,0,0.2);
  color: var(--text-muted);
  cursor: not-allowed;
}

.primary-btn {
  width: 100%;
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 1rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 1rem;
}

.primary-btn:hover {
  background: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.primary-btn:active {
  transform: translateY(0);
}

.history-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.history-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.75rem;
}

.history-title-row h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.danger-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
  color: #fff;
}

.search-controls {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 0.5rem;
}

@media (max-width: 1200px) {
  .search-controls {
    grid-template-columns: 1fr;
  }
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--input-border);
  border-radius: 4px;
}

.history-item {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.history-item:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.history-item h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  word-break: break-word;
  line-height: 1.4;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.meta-tag {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
  word-break: break-word;
}

.item-url {
  margin-bottom: 0.5rem;
}

.item-url a {
  color: var(--accent-color);
  text-decoration: none;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.item-url a:hover {
  text-decoration: underline;
}

.item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  text-align: right;
}

.item-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.item-header-actions {
  display: flex;
  gap: 0.5rem;
}

.copy-btn, .edit-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.copy-btn:hover, .edit-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.create-docs-btn {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.create-docs-btn:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.25);
}

.create-docs-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.item-memo {
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.5rem 0;
  border-left: 3px solid var(--accent-color);
  word-break: break-word;
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.edit-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  padding: 0.5rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
}

.edit-textarea {
  min-height: 80px;
  resize: vertical;
}

.edit-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.small-btn {
  width: auto;
  padding: 0.5rem 1rem;
  margin-top: 0;
}

.status-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.status-未保存 {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.status-Docs作成済み {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.status-Drive保存済み {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.status-要確認 {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

/* ===== PWA / iPhone / iPad レスポンシブ対応 ===== */

/* safe-area-inset（ノッチ・ホームバー対応） */
body {
  padding: env(safe-area-inset-top, 2rem) env(safe-area-inset-right, 2rem) env(safe-area-inset-bottom, 2rem) env(safe-area-inset-left, 2rem);
}

/* iOS自動ズーム防止：全入力要素を16px以上に */
input, textarea, select {
  font-size: max(16px, 0.95rem);
}

/* standalone表示時の追加padding */
@media (display-mode: standalone) {
  body {
    padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
  }
}

/* タブレット（iPad）レスポンシブ */
@media (max-width: 1024px) {
  .search-controls {
    grid-template-columns: 1fr 1fr;
  }
}

/* スマートフォン レスポンシブ */
@media (max-width: 600px) {
  body {
    padding: env(safe-area-inset-top, 1rem) 0.75rem env(safe-area-inset-bottom, 1rem) 0.75rem;
  }

  .app-header h1 {
    font-size: 1.75rem;
  }

  .glass-panel {
    padding: 1.25rem;
    border-radius: 12px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .search-controls {
    grid-template-columns: 1fr;
  }

  .history-list {
    max-height: calc(100vh - 200px);
    max-height: calc(100dvh - 200px);
  }

  /* タッチターゲット最適化：最小44px */
  .primary-btn,
  .danger-btn,
  .copy-btn,
  .edit-btn,
  .create-docs-btn {
    min-height: 44px;
    min-width: 44px;
  }

  select {
    min-height: 44px;
  }

  .item-header-actions {
    flex-wrap: wrap;
  }

  .history-item h3 {
    font-size: 1rem;
  }

  .item-meta {
    gap: 0.5rem;
  }

  .meta-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

/* 超小型画面（iPhone SE等） */
@media (max-width: 375px) {
  .app-header h1 {
    font-size: 1.4rem;
  }

  .badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
  }

  .glass-panel {
    padding: 1rem;
  }
}
