<!DOCTYPE html>
<html lang="{{session['language'] or 'ja'}}">

<head>
  <meta charset="UTF-8">
  <title>{% block title %}{% endblock %} ・ {{ localize("kanken_online") }}</title>
  <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
  {% if session %}
    <link rel="stylesheet" href="{{ url_for('static', filename='dark_theme.css') if session['theme'] == 'dark' else url_for('static', filename='light_theme.css')}}">
  {% else %}
    <link rel="stylesheet" href="{{ url_for('static', filename='theme_select.css') }}"> <!-- Use CSS-based theme detection if no user login supplied -->
  {% endif %}
  {% block styles %}{% endblock %}
  {% block scripts %}{% endblock %}
</head>
<body>
<nav>
  <h1><a href="/">{{ localize("kanken_online") }}</a></h1>
  <ul>
    {% if g.user %}
    <li><a href="{{ url_for('my_page') }}">{{ g.user['username'] }}</a>
    <li><a href="{{ url_for('auth.logout') }}">{{ localize("log_out") }}</a>
      {% else %}
    <li><a href="{{ url_for('auth.register') }}">{{ localize("register") }}</a>
    <li><a href="{{ url_for('auth.login') }}">{{ localize("log_in") }}</a>
      {% endif %}
    <li><a href="{{ url_for('options') }}">{{ localize("options") }}</a>
    <li><a href="{{ url_for('about_page') }}">{{ localize("about") }}</a></li>
    <li><a href="{{ url_for('indices.indices_page') }}">{{ localize("indices") }}</a></li>
    <li><a href="{{ url_for('search.search_page') }}">{{ localize("search") }}</a></li>
    <li><a href="{{ url_for('forum.index') }}">{{ localize("forum") }}</a></li>
    <li><a href="{{ url_for('data_page') }}">{{ localize("data") }}</a></li>
  </ul>
</nav>
<section class="content">
  <header>
    {% block header %}{% endblock %}
  </header>
  {% for message in get_flashed_messages() %}
  <div class="flash">{{ localize(message) }}</div>
  {% endfor %}
  {% block content %}{% endblock %}
</section>
</body>
</html>